package com.hackintosh.state.thread;

/**
 * @description：就绪状态
 * @author：twislyn
 * @date：Created in 2021/05/23
 * @modified By：
 * @version: 1.0
 */
public class Runnable extends AbstractThreadState {
    public Runnable() {
        this.stateName = "READY";
        System.out.println("当前线程处于：就绪状态.");
    }

    public void getCPU(ThreadContext threadContext) {
        System.out.print("获得CPU时间-->");
        if (this.stateName.equals("READY")) {
            threadContext.setState(new Running());
        } else {
            System.out.println("当前线程不是就绪状态，不能获取CPU.");
        }
    }
}
